package hs.framework.opcClient.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author Administrator
 * @date 2021-04-07 下午 5:35
 * @description 自动更新时间字段
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    /**
     *
     * @author Administrator
     * @date 2021-04-09 09:59:58
     * @description  给插入时自动填充的字段赋值
     * @return
     **/
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createTime", LocalDateTime.class,LocalDateTime.now());
        this.strictUpdateFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now());
    }

    /**
     *
     * @author Administrator
     * @date 2021-04-09 10:00:36
     * @description  给更新时自动填充的字段赋值
     * @return
     **/
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now());
    }
}
